package com.example.admin.brainwave.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.admin.brainwave.R;
import com.example.admin.brainwave.bean.DictionaryBean;

import java.util.List;

public class DictionaryAdapter extends BaseQuickAdapter<DictionaryBean, BaseViewHolder> {

    public DictionaryAdapter(int layoutResId, @Nullable List<DictionaryBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DictionaryBean item) {
        TextView textView = helper.getView(R.id.tv_dictionary_name);
        ImageView imageView = helper.getView(R.id.iv_dictionary_choose);
        textView.setText(item.getData());
        if (item.isChick()) {
            imageView.setVisibility(View.VISIBLE);
        } else {
            imageView.setVisibility(View.GONE);
        }
    }


    public void setChoose(int pos) {
        for (int i = 0; i < getData().size(); i++) {
            getData().get(i).setChick(false);
        }
        getData().get(pos).setChick(true);
        notifyDataSetChanged();
    }
}
